

package com.tool.Stall;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.come.baitan.ShouGou;
import org.come.bean.LoginResult;
import org.come.entity.Goodstable;
import org.come.entity.RoleSummoning;

// Referenced classes of package com.tool.Stall:
//			Commodity

public class Stall
{
	private int id;
	private int mapid;
	private String role;
	private BigDecimal roleid;
	private BigDecimal species_id;
	private String stall;
	private int state;
	private Commodity[] goodstables;
	private Commodity[] pets;
	private List<String> msg;
	private int x;
	private int y;
	private int guanzhu;
	private List<ShouGou> shouGous;
	public Stall(final LoginResult loginResult) {
		this.guanzhu = 0;
		this.species_id = loginResult.getSpecies_id();
		this.goodstables = new Commodity[24];
		this.pets = new Commodity[6];
		this.shouGous=new ArrayList<>();
	}

	public Commodity getCommodity(final int type, final int index) {
		if (type == 0) {
			return this.goodstables[index];
		}
		else {
			if (type == 1) {
				return this.pets[index];
			}
			else {
				return null;
			}
		}
	}

	public BigDecimal getSpecies_id() {
		return this.species_id;
	}

	public void setSpecies_id(final BigDecimal species_id) {
		this.species_id = species_id;
	}

	public int getId() {
		return this.id;
	}

	public void setId(final int id) {
		this.id = id;
	}

	public Commodity[] getGoodstables() {
		return this.goodstables;
	}

	public void setGoodstables(final Commodity[] goodstables) {
		this.goodstables = goodstables;
	}

	public Commodity[] getPets() {
		return this.pets;
	}

	public void setPets(final Commodity[] pets) {
		this.pets = pets;
	}

	public List<String> getMsg() {
		return this.msg;
	}

	public void setMsg(final List<String> msg) {
		this.msg = msg;
	}

	public int getMapid() {
		return this.mapid;
	}

	public void setMapid(final int mapid) {
		this.mapid = mapid;
	}

	public String getRole() {
		return this.role;
	}

	public void setRole(final String role) {
		this.role = role;
	}

	public BigDecimal getRoleid() {
		return this.roleid;
	}

	public void setRoleid(final BigDecimal roleid) {
		this.roleid = roleid;
	}

	public String getStall() {
		return this.stall;
	}

	public void setStall(final String stall) {
		this.stall = stall;
	}

	public int getState() {
		return this.state;
	}

	public void setState(final int state) {
		this.state = state;
	}

	public int getX() {
		return this.x;
	}

	public void setX(final int x) {
		this.x = x;
	}

	public int getY() {
		return this.y;
	}

	public void setY(final int y) {
		this.y = y;
	}

	public Commodity getGood(final BigDecimal rgid) {
		int i = 0;
		while (i < this.goodstables.length) {
			if (this.goodstables[i] != null && this.goodstables[i].getGood().getRgid().compareTo(rgid) == 0) {
				return this.goodstables[i];
			}
			else {
				++i;
			}
		}
		return null;
	}

	public Commodity getPet(final BigDecimal rgid) {
		int i = 0;
		while (i < this.pets.length) {
			if (this.pets[i] != null && this.pets[i].getPet().getSid().compareTo(rgid) == 0) {
				return this.pets[i];
			}
			else {
				++i;
			}
		}
		return null;
	}

	public int Buy(final Commodity commodity) {
		int i = 0;
		while (i < this.goodstables.length) {
			if (this.goodstables[i] != null && this.goodstables[i] == commodity) {
				this.goodstables[i] = null;
				return i;
			}
			else {
				++i;
			}
		}
		i = 0;
		while (i < this.pets.length) {
			if (this.pets[i] != null && this.pets[i] == commodity) {
				this.pets[i] = null;
				return i;
			}
			else {
				++i;
			}
		}
		return -1;
	}

	public boolean ysj(final Commodity commodity) {
		int i = 0;
		while (i < this.goodstables.length) {
			if (this.goodstables[i] != null && this.goodstables[i] == commodity) {
				return true;
			}
			else {
				++i;
			}
		}
		i = 0;
		while (i < this.pets.length) {
			if (this.pets[i] != null && this.pets[i] == commodity) {
				return true;
			}
			else {
				++i;
			}
		}
		return false;
	}

	public int getGuanzhu() {
		return this.guanzhu;
	}

	public void setGuanzhu(final int guanzhu) {
		this.guanzhu = guanzhu;
	}

	public List<ShouGou> getShouGous() {
		return shouGous;
	}

	public void setShouGous(List<ShouGou> shouGous) {
		this.shouGous = shouGous;
	}

	@Override
	public String toString() {
		return "Stall{id=" + this.id + ", mapid=" + this.mapid + ", role='" + this.role + '\'' + ", roleid=" + this.roleid + ", species_id=" + this.species_id + ", stall='" + this.stall + '\'' + ", state=" + this.state + ", goodstables=" + Arrays.toString((Object[])this.goodstables) + ", pets=" + Arrays.toString((Object[])this.pets) + ", msg=" + this.msg + ", x=" + this.x + ", y=" + this.y + ", guanzhu=" + this.guanzhu + '}';
	}
}
